home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 176-200 / disk_197 / stevie / stevie.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  6KB  |  296 lines

  1. /*
  2.  * STEVIE - Simply Try this Editor for VI Enthusiasts
  3.  *
  4.  * Code Contributions By : Tim Thompson           twitch!tjt
  5.  *                         Tony Andrews           onecom!wldrdg!tony 
  6.  *                         G. R. (Fred) Walter    watmath!watcgl!grwalter 
  7.  */
  8.  
  9. #include "env.h"
  10.  
  11. #include <stdio.h>
  12. #ifndef ATARI
  13. # ifndef UNIX
  14. #   include <stdlib.h>
  15. # endif
  16. #endif
  17. #include <ctype.h>
  18. #ifndef MWC
  19. # include <string.h>
  20. #endif
  21. #include "ascii.h"
  22. #include "keymap.h"
  23. #include "param.h"
  24. #include "term.h"
  25. #include "macros.h"
  26.  
  27. #ifdef AMIGA
  28. /*
  29.  * This won't be needed if you have a version of Lattice 4.01 without broken
  30.  * break signal handling.
  31.  */
  32. #include <signal.h>
  33. #endif
  34.  
  35. extern char    *strchr();
  36.  
  37. #define NORMAL             0
  38. #define CMDLINE             1
  39. #define INSERT             2
  40. #define APPEND             3
  41. #define UNDO             4
  42. #define REDO             5
  43. #define PUT             6
  44. #define FORWARD             7
  45. #define BACKWARD         8
  46. #define VALID             9
  47. #define NOT_VALID        10
  48. #define VALID_TO_CURSCHAR    11
  49.  
  50. /*
  51.  * Boolean type definition and constants 
  52.  */
  53. typedef int     bool_t;
  54.  
  55. #ifndef    TRUE
  56. #define    FALSE    (0)
  57. #define    TRUE    (1)
  58. #endif
  59. #define    SORTOF    (2)
  60. #define YES      TRUE
  61. #define NO       FALSE
  62. #define MAYBE    SORTOF
  63.  
  64. /*
  65.  * Maximum screen dimensions
  66.  */
  67. #define MAX_COLUMNS 140L
  68.  
  69. /*
  70.  * Buffer sizes
  71.  */
  72. #define CMDBUFFSIZE MAX_COLUMNS    /* size of the command processing buffer */
  73.  
  74. #define LSIZE        512    /* max. size of a line in the tags file */
  75.  
  76. #define IOSIZE     (1024+1)    /* file i/o and sprintf buffer size */
  77.  
  78. #define YANKSIZE    5200    /* yank buffer size */
  79. #define INSERT_SIZE 5300    /* insert, redo and undo buffer size must be
  80.                  * bigger than YANKSIZE */
  81. #define REDO_UNDO_SIZE 5400    /* redo, undo and (undo an undo) buffer size
  82.                  * must be bigger than INSERT_SIZE */
  83. #define READSIZE    5500    /* read buffer size must be bigger than
  84.                  * YANKSIZE and REDO_UNDO_SIZE */
  85.  
  86. /*
  87.  * SLOP is the amount of extra space we get for text on a line during editing
  88.  * operations that need more space. This keeps us from calling alloc every
  89.  * time we get a character during insert mode. No extra space is allocated
  90.  * when the file is initially read. 
  91.  */
  92. #define    SLOP    10
  93.  
  94. /*
  95.  * LINEINC is the gap we leave between the artificial line numbers. This
  96.  * helps to avoid renumbering all the lines every time a new line is
  97.  * inserted. 
  98.  *
  99.  * Since line numbers are stored in longs (32 bits), a LINEINC of 10000
  100.  * lets us have > 200,000 lines and we won't have to renumber very often.
  101.  */
  102. #define    LINEINC    10000
  103.  
  104. #define CHANGED   { Changed = TRUE; }
  105. #define UNCHANGED { Changed = FALSE; }
  106.  
  107. struct line {
  108.     struct line    *next;    /* next line */
  109.     struct line    *prev;    /* previous line */
  110.     char           *s;        /* text for this line */
  111.     int             size;    /* actual size of space at 's' */
  112.     unsigned long   num;    /* line "number" */
  113. };
  114.  
  115. #define    LINEOF(x)    ((x)->linep->num)
  116.  
  117. struct lptr {
  118.     struct line    *linep;    /* line we're referencing */
  119.     int             index;    /* position within that line */
  120. };
  121.  
  122. typedef struct line LINE;
  123. typedef struct lptr LPtr;
  124.  
  125. struct charinfo {
  126.     char            ch_size;
  127.     char           *ch_str;
  128. };
  129.  
  130. extern struct charinfo chars[];
  131.  
  132. extern int      State;
  133. extern int      Rows;
  134. extern int      Columns;
  135. extern char    *Realscreen;
  136. extern char    *Nextscreen;
  137. extern int      NumLineSizes;
  138. extern LINE   **LinePointers;
  139. extern char    *LineSizes;
  140. extern char    *Filename;
  141. extern LPtr    *Filemem;
  142. extern LPtr    *Filetop;
  143. extern LPtr    *Fileend;
  144. extern LPtr    *Topchar;
  145. extern LPtr    *Botchar;
  146. extern LPtr    *Curschar;
  147. extern LPtr    *Insstart;
  148. extern int      Cursrow, Curscol, Cursvcol, Curswant;
  149. extern bool_t   set_want_col;
  150. extern int      Prenum;
  151. extern bool_t   Changed;
  152. extern bool_t   RedrawingDisabled;
  153. extern bool_t   MustRedrawLine;
  154. extern bool_t   MustRedrawScreen;
  155. extern bool_t   UndoInProgress;
  156. extern bool_t   Binary;
  157. extern char    *IObuff;
  158. extern char    *Insbuffptr;
  159. extern char    *Insbuff;
  160. extern char    *Readbuffptr;
  161. extern char    *Readbuff;
  162. extern char    *Redobuffptr;
  163. extern char    *Redobuff;
  164. extern char    *Undobuffptr;
  165. extern char    *Undobuff;
  166. extern char    *UndoUndobuffptr;
  167. extern char    *UndoUndobuff;
  168. extern char    *Yankbuffptr;
  169. extern char    *Yankbuff;
  170. extern char     last_command;
  171. extern char     last_command_char;
  172.  
  173. extern char    *strcpy();
  174.  
  175. /* alloc.c */
  176. char  *alloc();
  177. char  *strsave();
  178. void   screenalloc(), filealloc(), freeall();
  179. LINE  *newline();
  180. bool_t canincrease();
  181.  
  182. /* cmdline.c */
  183. void   readcmdline();
  184. void   dotag();
  185. void   msg(), emsg(), smsg();
  186. void   gotocmdline();
  187. void   wait_return();
  188.  
  189. /* dec.c */
  190. int    dec();
  191.  
  192. /* edit.c */
  193. void   edit(), insertchar(), getout(), scrollup(), scrolldown(), beginline();
  194. bool_t oneright(), oneleft(), oneup(), onedown();
  195.  
  196. /* fileio.c */
  197. void   filemess(), renum();
  198. bool_t readfile(), writeit();
  199.  
  200. /* updateNs.c */
  201. void   updateNextscreen();
  202.  
  203. /* updateRs.c */
  204. void   updateRealscreen();
  205.  
  206. /* help.c */
  207. bool_t help();
  208.  
  209. /* inc.c */
  210. int    inc();
  211.  
  212. /* linefunc.c */
  213. LPtr   *nextline(), *prevline(), *coladvance();
  214.  
  215. /* main.c */
  216. void   stuffReadbuff();
  217. void   stuffnumReadbuff();
  218. char   vgetc();
  219. char   vpeekc();
  220.  
  221. /* mark.c */
  222. void   setpcmark(), clrall(), clrmark();
  223. bool_t setmark();
  224. LPtr  *getmark();
  225.  
  226. /* misccmds.c */
  227. bool_t OpenForward();
  228. bool_t OpenBackward();
  229. void   fileinfo(), inschar(), insstr(), delline();
  230. bool_t delchar();
  231. int    cntllines(), plines();
  232. LPtr  *gotoline();
  233.  
  234. /* normal.c */
  235. void   normal();
  236. void   ResetBuffers();
  237. void   AppendToInsbuff();
  238. void   AppendToRedobuff();
  239. void   AppendNumberToRedobuff();
  240. void   AppendToUndobuff();
  241. void   AppendNumberToUndobuff();
  242. void   AppendPositionToUndobuff();
  243. void   AppendToUndoUndobuff();
  244. void   AppendNumberToUndoUndobuff();
  245. void   AppendPositionToUndoUndobuff();
  246. bool_t linewhite();
  247.  
  248. /* mk.c */
  249. char  *mkstr();
  250. char  *mkline();
  251.  
  252. /* param.c */
  253. void   doset();
  254.  
  255. /* screen.c */
  256. void   nexttoscreen();
  257. void   updateline();
  258. void   redrawline();
  259. void   screenclear();
  260. void   cursupdate();
  261. void   prt_line();
  262. void   s_del();
  263. void   s_ins();
  264.  
  265. /* search.c */
  266. void   doglob();
  267. void   dosub();
  268. void   searchagain();
  269. bool_t dosearch();
  270. bool_t repsearch();
  271. bool_t searchc(), crepsearch(), findfunc();
  272. LPtr  *showmatch();
  273. LPtr  *fwd_word(), *bck_word(), *end_word();
  274.  
  275. /*
  276.  * Machine-dependent routines. 
  277.  */
  278. #ifdef AMIGA
  279. # include "amiga.h"
  280. #endif
  281. #ifdef BSD
  282. # include "bsd.h"
  283. #endif
  284. #ifdef UNIX
  285. # include "unix.h"
  286. #endif
  287. #ifdef TOS
  288. # include "tos.h"
  289. #endif
  290. #ifdef OS2
  291. # include "os2.h"
  292. #endif
  293. #ifdef DOS
  294. # include "dos.h"
  295. #endif
  296.